package com.neusoft.neuiotms.dcam.fixed.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;
import com.neusoft.neuiotms.dcam.common.model.Location;
import com.neusoft.neuiotms.dcam.common.model.Manufacturer;

import lombok.Getter;
import lombok.Setter;

/**
 * 资产
 *
 * @author sunchf
 */
@Getter
@Setter
@Entity
@Table(name = "neuiot_fixed_asset")
@org.hibernate.annotations.Table(appliesTo = "neuiot_fixed_asset", comment = "固定资产表")
public class Asset extends AbstractAuditModel {

    private static final long serialVersionUID = 1L;

    @Length(max = 255, message = "固资编号不能超过{max}位")
    @Column(length = 255, nullable = false, unique = true)
    @Comment("varchar(255) NOT NULL COMMENT '资产编号'")
    private String code;

    @NotNull(message = "资产类型不能为空")
    @ManyToOne
    private AssetType type;

    @NotBlank(message = "资产名不能为空")
    @Length(max = 255, message = "资产名不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '资产名称'")
    private String name;

    /** 账套 */
    @Length(max = 255, message = "不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) '账套'")
    private String books;

    /** 投产日期 */
    @Column(length = 255, nullable = true)
    @Comment("Date COMMENT '投产日期'")
    private Date usedate;

    /** 取得日期 */
    @Column(length = 255, nullable = true)
    @Comment("Date COMMENT '取得日期'")
    private Date getdate;

    /** 自用价值 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '自用价值'")
    private Double ownvalue;

    /** 折旧状态 */
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) COMMENT '折旧状态'")
    private String depreciationstatus;

    /** 已折旧 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '已折旧（月）'")
    private Double depreciationmonth;

    /** 已折旧 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '累计折旧'")
    private Double depreciationtotal;

    /** 使用期限 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '使用期限（月）'")
    private Double month;

    /** 价值类型 */
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) COMMENT '价值类型'")
    private String valuetype;

    /** 价值 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '价值'")
    private Double money;

    /** 财政性资金 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '财政性资金'")
    private Double fundsfinancial;

    /** 财政性资金 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '非财政性资金'")
    private Double unfundsfinancial;

    /** 净值 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '净值'")
    private Double equity;

    //    @Enumerated(EnumType.STRING)
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) COMMENT '资产来源'")
    private String source = "purchase";

    /** 使用方向 */
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) COMMENT '使用方向'")
    private String usetype;

    /** 使用状况 */
    @NotNull(message = "资产状态不能为空")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) COMMENT '资产状态'")
    private String status = "idle";

    /** 使用部门名称 */
    @Length(max = 255, message = "使用部门不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '使用部门'")
    private String useDept;

    /** 管理部门 */
    @Length(max = 255, message = "管理部门不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '管理部门'")
    private String manageDept;

    /** 使用ren姓名 */
    @Length(max = 255, message = "使用人不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '使用人'")
    private String userName;

    /** 数量 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '数量'")
    private Double quantity;

    /** 制单人 */
    @Length(max = 255, message = "制单人不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '制单人'")
    private String creator;

    /** 所属单位 */
    @Length(max = 255, message = "所属单位不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '所属单位'")
    private String belongTo;

    /** 移交单位 */
    @Length(max = 255, message = "移交单位不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '移交单位'")
    private String submmitTo;

    /** 规格型号 */
    @Length(max = 255, message = "规格型号不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '规格型号'")
    private String specification;

    /** 存放地点 */
    @Length(max = 255, message = "存放地点不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '存放地点'")
    private String located;

    /** 原资产编号 */
    @Length(max = 255, message = "原资产编号不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '原资产编号'")
    private String originCode;

    /** 品牌 */
    @Length(max = 255, message = "品牌不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '品牌'")
    private String brand;

    /** 闲置价值 */
    @Column(length = 255, nullable = true)
    @Comment("double(255,2) COMMENT '闲置价值'")
    private Double idleValue;

    /** 制单时间 */
    @Column(length = 255, nullable = true)
    @Comment("Date COMMENT '制单时间'")
    private Date handoverDate;

    /** 备用字段 */
    @Length(max = 255, message = "备用字段不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '备用字段'")
    private String backup;

    /** 备注 */
    @Length(max = 2550, message = "备注不能超过{max}位")
    @Column(length = 2550, nullable = true)
    @Comment("varchar(2550) NULL DEFAULT NULL COMMENT '备注'")
    private String remark;

    /** 用途 */
    @Length(max = 255, message = "用途不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '用途'")
    private String purpose;

    /** 生产厂家 */
    @Length(max = 255, message = "生产厂家不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '生产厂家'")
    private String produce;

    /** 维保截至时间 */
    @Column(length = 255, nullable = true)
    @Comment("Date COMMENT '维保截至时间'")
    private Date manufacturerEndDate;

    /** 交接文档是否齐全 */
    @Column(length = 255, nullable = true)
    @Comment("boolean COMMENT '交接文档是否齐全'")
    private Boolean isDocumentAll;

    /** 对应支撑的业务应用系统 */
    @Length(max = 255, message = "对应支撑的业务应用系统不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '对应支撑的业务应用系统'")
    private String businessSystem;

    /** 合同编号以及名称 */
    @Length(max = 255, message = "合同编号以及名称不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '合同编号以及名称'")
    private String contractNameAndCode;

    /** 序列号 */
    @Length(max = 255, message = "序列号不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '序列号'")
    private String sequence;

    /** 是否报废 */
    @Column(length = 255, nullable = true)
    @Comment("boolean COMMENT '是否报废'")
    private Boolean isScrapped;

    /** 厅局机房地址 */
    @Length(max = 255, message = "厅局机房地址不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '厅局机房地址'")
    private String officeComputerRoomAddress;

    /** 厅局地址 */
    @Length(max = 255, message = "厅局地址不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '厅局地址'")
    private String officeAddress;

    //    //    @Enumerated(EnumType.STRING)
    //    //    @NotNull(message = "资产状态不能为空")
    //    //    @Column(length = 255, nullable = false)
    //    //    @Comment("varchar(255) COMMENT '资产状态'")
    //    //    private AssetStatus status = AssetStatus.idle;

    /** 以下是海南资产不使用字段 **/

    /** 使用部门名称 */
    @Length(max = 255, message = "使用部门不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '使用部门'")
    private String orgName;

    /** 使用部门 */
    @Length(max = 255, message = "使用部门不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '使用部门'")
    private String orgId;

    /** 合同编号以及名称 */
    @Length(max = 255, message = "实际移交单位不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '实际移交单位'")
    private String secondeDept;

    /** 合同编号以及名称 */
    @Length(max = 255, message = "移交二级下属单位不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Deprecated
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '移交二级下属单位'")
    private String thirdDept;

    /** 扩展属性1 */
    @Length(max = 255, message = "不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String ext1;

    /** 扩展属性2 */
    @Length(max = 255, message = "不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String ext2;

    /** 扩展属性3 */
    @Length(max = 255, message = "不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String ext3;

    /** 扩展属性4 */
    @Length(max = 255, message = "不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String ext4;

    /** 扩展属性5 */
    @Length(max = 255, message = "不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String ext5;

    /** 产品 */
    @ManyToOne
    private Product product;

    /** 供应商 */
    @ManyToOne
    private Manufacturer manufacturer;

    /** 维保 */
    @OneToOne(cascade = CascadeType.ALL)
    private Maintenance maintenance;

    /** 计量单位 */
    @Length(max = 255, message = "使用人不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '计量单位'")
    private String measureUnit;

    //    @Enumerated(EnumType.STRING)
    //    @NotNull(message = "资产来源不能为空")
    //    @Column(length = 255, nullable = false)
    //    @Comment("varchar(255) COMMENT '资产来源'")
    //    private AssetSource source = AssetSource.purchase;

    @ManyToOne(fetch = FetchType.LAZY)
    private Contract contract;

    @ManyToOne
    private Location location;

    /** 使用人 */
    @Column(length = 255, nullable = true)
    @Comment("varchar(255) NULL DEFAULT NULL COMMENT '使用人'")
    private String userId;

    @Column(length = 255, nullable = true)
    @Comment("varchar(255 NULL DEFAULT NULL )")
    private String running;
}
